# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=delve
pkgver=1.23.1
pkgrel=0
pkgdesc="Debugger for the Go programming language"
url="https://github.com/go-delve/delve"
arch="x86 x86_64 aarch64"
license="MIT"
makedepends="go"
options="net chmod-clean"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/go-delve/delve/archive/refs/tags/v$pkgver.tar.gz"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	mkdir bin
	go build -v -trimpath -o bin ./cmd/dlv/...
}

check() {
	# TestGeneratedDoc and TestBuild require a proper $GOPATH setup.
	go test -run '!(^(TestGeneratedDoc|TestBuild)$)' ./cmd/dlv/...
}

package() {
	install -Dm755 bin/* -t "$pkgdir"/usr/bin/

	# Install additional documentation files.
	mkdir -p "$pkgdir"/usr/share/doc/$pkgname
	cp -r Documentation/* "$pkgdir"/usr/share/doc/$pkgname

	install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}

sha512sums="
1f88b5aa7d0442b5c4f79be5cf465d76bc3849e849f36677f36735a57b117db0a3cdecc2bbc215573d9fcdae724e6f50b792550b6188e844e392d9a659281dfe  delve-1.23.1.tar.gz
"
